package com.emotionsns;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.TextView;

public class TranslucentBlurTextActivity extends Activity {
	TextView textView;

	@Override
	protected void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		textView = new TextView(this);
		textView.setTextColor(Color.WHITE);
		textView.setGravity(Gravity.CENTER);
		setContentView(textView);
		 getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
		 WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
		new TextWrite(handler, getIntent().getExtras().getString("twit"));
	}

	public boolean onTouchEvent(android.view.MotionEvent event) {
		onBackPressed();
		return false;
	}

	Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			textView.setText((String) msg.obj);
		}
	};

	class TextWrite extends Thread {
		Handler handler;
		String contents;

		public TextWrite(Handler handler, String contents) {
			// TODO Auto-generated constructor stub
			this.handler = handler;
			this.contents = contents;
			this.setDaemon(true);
			this.start();
		}

		@Override
		public void run() {
			// TODO Auto-generated method stub
			for (int i = 0; i < contents.length(); i++) {
				try {
					Message msg = new Message();
					msg.obj = contents.substring(0, i);
					handler.sendMessage(msg);
					Thread.sleep(50);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}
